package com.yuanfeng.business.controller;


import com.yuanfeng.business.dto.ShopClassBindDTO;
import com.yuanfeng.commoms.exception.BizCodeEnume;
import com.yuanfeng.commoms.util.ResponseResult;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @ClassName ShopClassBindController
 * @Description  店铺经营类目-更新绑定类目时备份-孟响-19/04/16

 * @Author cyp
 * @Date 2023-07-04 16:28:28
 * @Version 1.0
 **/
@RestController
@RequestMapping("shop/classBind")
public class ShopClassBindController extends BaseController {

    /**
     * 判断 当前商家的经营类目是否允许同步该商品
     *
     * @return
     */
    @PostMapping("verifyBusinessCategory")
    public ResponseResult verifyBusinessCategory(@RequestBody Map<String,Object> pram){
        return shopClassBindService.verifyBusinessCategory(pram);
    }


    /**
     * 删除经营类目申请
     *
     * @param param
     * @return
     */
    @PostMapping("/deleteBind")
    public ResponseResult deleteShopClassBindList(@RequestBody ShopClassBindDTO param) {
        ResponseResult result = shopClassBindService.deleteShopClassBindList(param);
        return result;
    }


    /**
     * 更新店铺经营类目
     *
     * @param param
     * @return
     */
    @PostMapping("/update/supply/cat")
    public ResponseResult updateSupplyShopCats(@RequestBody ShopClassBindDTO param) {
        //校验参数
        if (null == param.getProductClassId()) {
            return ResponseResult.fail(BizCodeEnume.VALID_EXCEPTION);
        } else {
            ResponseResult result = shopClassBindService.updateSupplyShopCats(param);
            return result;
        }
    }


    /**
     * 查询店铺经营类目
     *
     * @param param
     * @return
     */
    @PostMapping("/query/list")
    public ResponseResult queryShopClassBindList(@RequestBody ShopClassBindDTO param) throws IllegalAccessException {
        ResponseResult result = shopClassBindService.queryShopClassBindList(param);
        return result;
    }

    /**
     * 删除绑定的入驻分类
     *
     * @param productClassId
     * @return
     */
    @GetMapping("/deleteBindGoodsCat")
    public ResponseResult deleteBindGoodsCat(@RequestParam("productClassId") Integer productClassId) {
        ResponseResult result = shopClassBindService.deleteBindGoodsCat(productClassId);
        return result;
    }
}
